package com.qd.common.panda.domain.enums;

import org.springframework.util.StringUtils;

/**
 * 加油站类型
 * PETRO_CHINA	中石油
 * SINOPEC	中石化
 * SHELL	壳牌
 * GAS_TYPE_OTHER	其他
 *
 * @author sjk
 */
public enum GasStationTypeEnum {
    /**
     * 中石油
     */
    PETRO_CHINA("PETRO_CHINA", "中石油"),
    /**
     * 中石化
     */
    SINOPEC("SINOPEC", "中石化"),
    /**
     * 壳牌
     */
    SHELL("SHELL", "壳牌"),
    /**
     * 其他
     */
    GAS_TYPE_OTHER("GAS_TYPE_OTHER", "其他");

    final String code;
    final String msg;

    GasStationTypeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static String idToDisplay(String code) {
        String msg = "";
        if (StringUtils.hasLength(code)) {
            for (GasStationTypeEnum gasStationTypeEnum : values()) {
                if (gasStationTypeEnum.getCode().equals(code)) {
                    msg = gasStationTypeEnum.getMsg();
                }
            }
        }
        return msg;
    }

    public static String displayToId(String displayName) {
        String code = "";
        if (StringUtils.hasLength(displayName)) {
            for (GasStationTypeEnum gasStationTypeEnum : values()) {
                if (gasStationTypeEnum.getMsg().equals(displayName)) {
                    code = gasStationTypeEnum.getCode();
                }
            }
        }
        return code;
    }
}
